﻿Imports System.Net
Imports System.Net.Sockets

Namespace TCP

    ''' <summary>
    ''' 接收客户端连接事件参数
    ''' </summary>
    ''' <remarks></remarks>
    Public Class AcceptEventArgs
        Inherits EventArgs

        Private m_remoteEndPoint As IPEndPoint
        Private m_clientSocket As ClientInfo

        ''' <summary>
        ''' 远程主机地址信息
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property RemoteEndPoint() As IPEndPoint
            Get
                Return m_remoteEndPoint
            End Get
            Set(ByVal value As IPEndPoint)
                m_remoteEndPoint = value
            End Set
        End Property

        ''' <summary>
        ''' 客户端Socket
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property Client() As ClientInfo
            Get
                Return m_clientSocket
            End Get
            Set(ByVal value As ClientInfo)
                m_clientSocket = value
            End Set
        End Property

    End Class

    ''' <summary>
    ''' 接收数据事件参数
    ''' </summary>
    ''' <remarks></remarks>
    Public Class ReceiveEventArgs
        Inherits EventArgs

        Private m_length As Integer

        ''' <summary>
        ''' 接收数据的长度(字节)
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property Length() As Integer
            Get
                Return m_length
            End Get
            Set(ByVal value As Integer)
                m_length = value
            End Set
        End Property

        Public Sub New()

        End Sub

        Public Sub New(ByVal length As Integer)
            Me.m_length = length
        End Sub
    End Class

    Public Class DisconnectArgs
        Inherits EventArgs

        Public Type As DisconnectType
        'Public client As ClientInfo

        Public Sub New()

        End Sub
        Public Sub New(ByVal type As DisconnectType)
            Me.Type = type
        End Sub
        'Public Sub New(ByVal type As DisconnectType, ByRef client As ClientInfo)
        '    Me.type = type
        '    Me.client = client
        'End Sub

    End Class

    ''' <summary>
    ''' 连接至服务器事件参数
    ''' </summary>
    ''' <remarks></remarks>
    Public Class ConnectEventArgs
        Inherits EventArgs

        Private m_remoteEndPoint As IPEndPoint

        ''' <summary>
        ''' 远程主机地址信息
        ''' </summary>
        ''' <value></value>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Public Property RemoteEndPoint() As IPEndPoint
            Get
                Return m_remoteEndPoint
            End Get
            Set(ByVal value As IPEndPoint)
                m_remoteEndPoint = value
            End Set
        End Property

        Public Sub New(ByVal remoteEndPoint As IPEndPoint)
            m_remoteEndPoint = remoteEndPoint
        End Sub
    End Class

    ''' <summary>
    ''' 等待心跳包响应事件参数
    ''' </summary>
    ''' <remarks></remarks>
    Public Class HeartWaitArgs
        Inherits EventArgs

        ''' <summary>
        ''' 心跳包发送次数
        ''' </summary>
        ''' <remarks></remarks>
        Public times As Integer

        Public Sub New(ByVal times As Integer)
            Me.times = times
        End Sub
    End Class

    Public Enum DisconnectType
        Active
        Normal
        ConnectionReset
        ConnectionAborted
        Shutdown
        HeartTimeout
        TimedOut
    End Enum

End Namespace
